package xyz.jangle.io;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class OutputToFile {

	public static void main(String[] args) {
		
//		String fileName = "test4.txt";
//		String dirName = "D:/d";
//		File file = new File(dirName);
//		if(!file.exists()) {
//			file.mkdirs();
//		}
		
		try(OutputStream out =  new FileOutputStream("D:/test4.txt");
				OutputStream out2 = new BufferedOutputStream(out)) {
			for (int i = 0; i < 500; i++) {
				String str = ""+i+"\n";
				out2.write(str.getBytes());
			}
			out2.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

	}

}
